package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.mapper.TripTypeMapper;
import com.ruoyi.system.domain.TripType;
import com.ruoyi.system.service.ITripTypeService;

/**
 * 出行类型Service业务层处理
 *
 * @author trip
 * @date 2024-09-20
 */
@Service
public class TripTypeServiceImpl extends ServiceImpl<TripTypeMapper, TripType> implements ITripTypeService {

    @Autowired
    private TripTypeMapper tripTypeMapper;

    /**
     * 查询出行类型
     *
     * @param tripTypeId 出行类型主键
     * @return 出行类型
     */
    @Override
    public TripType selectTripTypeByTripTypeId(Long tripTypeId) {
        return tripTypeMapper.selectTripTypeByTripTypeId(tripTypeId);
    }

    /**
     * 查询出行类型列表
     *
     * @param tripType 出行类型
     * @return 出行类型
     */
    @Override
    public List<TripType> selectTripTypeList(TripType tripType) {
        return tripTypeMapper.selectTripTypeList(tripType);
    }

    /**
     * 新增出行类型
     *
     * @param tripType 出行类型
     * @return 结果
     */
    @Override
    public int insertTripType(TripType tripType) {
                tripType.setCreateTime(DateUtils.getNowDate());
            return tripTypeMapper.insertTripType(tripType);
    }

    /**
     * 修改出行类型
     *
     * @param tripType 出行类型
     * @return 结果
     */
    @Override
    public int updateTripType(TripType tripType) {
                tripType.setUpdateTime(DateUtils.getNowDate());
        return tripTypeMapper.updateTripType(tripType);
    }

    /**
     * 批量删除出行类型
     *
     * @param tripTypeIds 需要删除的出行类型主键
     * @return 结果
     */
    @Override
    public int deleteTripTypeByTripTypeIds(Long[] tripTypeIds) {
        
            LambdaUpdateWrapper<TripType> wrapper;
            for (Long id : tripTypeIds) {
                wrapper = Wrappers.lambdaUpdate(TripType.class)
                .eq(TripType::getTripTypeId, id)
                    .set(TripType::getDelFlag, "1");
                super.update(new TripType(), wrapper);
            }
            return 1;
    }

    /**
     * 删除出行类型信息
     *
     * @param tripTypeId 出行类型主键
     * @return 结果
     */
    @Override
    public int deleteTripTypeByTripTypeId(Long tripTypeId) {
        return tripTypeMapper.deleteTripTypeByTripTypeId(tripTypeId);
    }
}



